-
Notifications
You must be signed in to change notification settings - Fork 0
Add wrapper struct to durable events and store trace context #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This should result in Sentry displaying a link from the task execution trace (where 'await_event' is called) back to the trace that performed the 'emit_event' call Note that this is a *breaking change*, as we now wrap the user's payload in a struct when reading/writing to the database. Going forward, we'll be able to add new (optional) fields to this wrapper struct without breaking existing durable deployments
|
@virajmehta I opted to always store a json object that looks like |
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec45961deb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| if not p_payload ? 'metadata' then | ||
| raise exception 'p_payload must contain a ''metadata'' key'; | ||
| end if; | ||
| end if; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQL validation allows non-object payloads causing Rust errors
Low Severity
The SQL validation in emit_event only validates payloads when jsonb_typeof(p_payload) = 'object'. Non-object JSON values (strings, numbers, arrays, booleans) bypass validation entirely but will cause deserialization failures in Rust, since AwaitEventResult.payload expects a DurableEventPayload structure. The reviewer requested to "enforce that exactly these two keys are present" which implies non-conforming payloads should be rejected, not silently allowed. Direct SQL calls with non-object payloads would store invalid data.
This should result in Sentry displaying a link from the task execution trace (where 'await_event' is called) back to the trace that performed the 'emit_event' call
Note that this is a breaking change, as we now wrap the user's payload in a struct when reading/writing to the database. Going forward, we'll be able to add new (optional) fields to this wrapper struct without breaking existing durable deployments
Note
High Risk
High risk because it introduces a breaking change to the persisted event payload JSON format and adds DB-side validation, impacting all producers/consumers of
emit_event/await_eventand internal child completion events.Overview
All durable events are now persisted and transported as a structured wrapper
DurableEventPayloadwith{ inner, metadata }instead of storing the user payload directly.Durable::emit_event/emit_event_withnow wraps the user payload intoinnerand (when telemetry is enabled) injects trace context intometadata, whileTaskContext::await_event/joinunwrapinnerand optionally link spans using the extracted metadata.Postgres functions are updated via a new migration (and
schema.sql) to enforce the wrapper shape indurable.emit_eventand to emit child completion events using the new wrapper format; tests that call SQLemit_eventdirectly are updated accordingly.Written by Cursor Bugbot for commit 8ac0de2. This will update automatically on new commits. Configure here.